package com.chengxiaoxiao.utils;

import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.PushPayload;

public class JPushUtils {

    protected static final String APP_KEY = "c7694a23b1fec33c8578ed3c";
    protected static final String MASTER_SECRET = "d2c3a505adc1d2f187d17382";

    public static void push(String msg) {
        ClientConfig clientConfig = ClientConfig.getInstance();
        JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, ClientConfig.getInstance());
        PushPayload payload = buildPushObject_all_all_alert(msg);

        try {
            PushResult result = jpushClient.sendPush(payload);
         
            System.out.println(result);

        } catch (APIConnectionException e) {
         
        } catch (APIRequestException e) {
            
        }
    }

    public static PushPayload buildPushObject_all_all_alert(String msg) {
        return PushPayload.alertAll(msg);
    }
}
